package com.crm.service.saling.impl;

import com.crm.dao.saling.PayDao;
import com.crm.exception.ServiceException;
import com.crm.pojo.Pay;
import com.crm.service.saling.PayService;
import com.crm.vo.PayClientContractUserInfoVOList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by dr5hx on 2018/9/3
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class PayServiceImpl implements PayService {
    @Autowired
    private PayDao payDao;

    @Override
    public Long getPayListCount() {
        return payDao.getPayListCount();
    }

    @Override
    public Pay findOne(Long payId) {
        return payDao.findOne(payId);
    }

    @Override
    public List<PayClientContractUserInfoVOList> getPayClientContractUserInfoVOList(int page, int rows) throws ServiceException {
        try {
            return payDao.getPayClientContractUserInfoVOList(new PageRequest(page - 1, rows));
        } catch (Exception e) {
            e.printStackTrace();
            throw new ServiceException(e);
        }
    }

    @Override
    public Pay save(Pay pay) throws ServiceException {
        try {
            return payDao.save(pay);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ServiceException(e);
        }
    }
}
